package com.lijie.bs_recruit.controller;


import com.github.pagehelper.PageInfo;
import com.lijie.bs_recruit.VO.ResultVO;
import com.lijie.bs_recruit.model.Jobfaircompany;
import com.lijie.bs_recruit.service.JobfairCompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lijie
 * @since 2021-04-07
 */
@RestController
@RequestMapping("/jobfaircompany")
public class JobfairCompanyController {
    @Autowired
    JobfairCompanyService jobfairCompanyService;

    @RequestMapping("/addJobfaircompany")
    public ResultVO<Jobfaircompany> addJobfaircompany(@RequestBody Jobfaircompany jobfaircompany){
        ResultVO<Jobfaircompany> ResultVO=new ResultVO<>();
        Jobfaircompany jobfaircompany1 = jobfairCompanyService.selJobfaircompanyByIds(jobfaircompany.getJobfairId(), jobfaircompany.getCompanyId());
        if(jobfaircompany1==null){
            Boolean aBoolean = jobfairCompanyService.addJobFairBusiness(jobfaircompany);
            if(aBoolean) ResultVO.setMessage("succ");
            else ResultVO.setMessage("error");
        }else{
            ResultVO.setMessage("isExist");
        }
        return ResultVO;
    }
    @RequestMapping("/selJobfaircompany/{pageIndex}")
    public PageInfo<Jobfaircompany> selJobfaircompany(@PathVariable Integer pageIndex, @RequestBody Jobfaircompany jobfaircompany){
        PageInfo<Jobfaircompany> jobfaircompanyPageInfo = jobfairCompanyService.selectJobFair(pageIndex, jobfaircompany);
        return jobfaircompanyPageInfo;
    }


}

